home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Essential Structures / RandomClearResizeRedraw / RandomClearResizeRedraw.cs next >
Encoding:
Text File  |  2001-01-15  |  861 b   |  28 lines

  1. //------------------------------------------------------
  2. // RandomClearResizeRedraw.cs ⌐ 2001 by Charles Petzold
  3. //------------------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class RandomClearResizeRedraw: Form
  9. {
  10.      public static void Main()      
  11.      {
  12.           Application.Run(new RandomClearResizeRedraw());
  13.      }
  14.      public RandomClearResizeRedraw()      
  15.      {
  16.           Text = "Random Clear with Resize Redraw";
  17.           ResizeRedraw = true;
  18.      }
  19.      protected override void OnPaint(PaintEventArgs pea)
  20.      {
  21.           Graphics grfx = pea.Graphics;
  22.           Random   rand = new Random();
  23.  
  24.           grfx.Clear(Color.FromArgb(rand.Next(256),
  25.                                     rand.Next(256),
  26.                                     rand.Next(256)));
  27.      }
  28. }